import java.util.Objects;

// 学生类，封装学生信息
public class Student {
    private String id;       // 学号
    private String name;     // 姓名
    private int age;         // 年龄
    private double score;    // 分数

    // 构造方法
    public Student(String id, String name, int age, double score) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.score = score;
    }

    // getter方法（用于比较和输出）
    public String getId() { return id; }
    public String getName() { return name; }
    public int getAge() { return age; }
    public double getScore() { return score; }

    // 重写toString，方便输出学生信息
    @Override
    public String toString() {
        return "[" + id + "," + name + "," + age + "," + score + "]";
    }

    // 重写equals和hashCode，确保学生对象的唯一性（基于学号）
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(id, student.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}

